% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_outcome.R
\name{get_cces_question}
\alias{get_cces_question}
\title{Get one column of outcome questions for each model}
\usage{
get_cces_question(
  qcode,
  year,
  qID,
  dataframe = NULL,
  y_named_as = "response",
  data_dir = "data/input/cces",
  verbose = TRUE
)
}
\arguments{
\item{qcode}{A string, the variable name of the outcome variable of interest,
exactly as it appears in the CCES dataset. Together with \code{year}, uniquely identifies
the outcome question data}

\item{year}{A string for the year the question was asked, which defines the
the \emph{dataset}. If using a dataset from the cumulative, set to \code{"cumulative"}.
Together with \code{qcode}, uniquely identifies the outcome question data}

\item{qID}{A string, the user's unique name for the question. For example, we use the
syntax in our question table.}

\item{dataframe}{An optional argument to pass the entire CCES dataframe in-environment.
If left empty, this will supersede the arguments \code{year} and \code{dataframe} and
use the provided datasets instead.}

\item{y_named_as}{What to name the response variable. Defaults to "response", which is also
the default assumption for \link{cces_join_slim}.}

\item{data_dir}{A path for the directory where flat files for the CCES common content is
stored.  Currently the data must be of the form \verb{cces_\{year\}.rds}  (e.g. \code{"cces_2016.rds"})
and it must exist wherever \code{data_dir} is. We recommend looping over \link{get_cces_dataverse}
to download data first.}

\item{verbose}{whether to print a message; defaults to TRUE}
}
\value{
A three-column dataframe with the columns
\describe{
\item{year}{The year}
\item{case_id}{The respondent identifier within year}
\item{qID}{The question ID}
\item{response}{The outcome question, of class factor}
}
The object will also have an attribute called \code{question}, which will save
the question identifier \code{qID}
}
\description{
Get one column of outcome questions for each model
}
\details{
This transformation currently only supports Yes/No questions. For some common
ordinal questions that can, with manual recodes, be set to a Yes/No question,
there is some hard-coding of the recode in the question. In the future, this should be
defined outside of the function in a taxonomy.
}
\examples{

 # with sample data
 get_cces_question("pid3", dataframe = cc18_samp, year = 2018, qID = "pid3")

 # need data/input/cces/cces_2018.rds to run this
 \dontrun{
  get_cces_question(qcode = "CC18_326", year = "2018", qID = "TCJA")

  # A tibble: 60,000 x 4
  # year   case_id qID   response
  # <int>     <int> <chr> <fct>
  # 1  2018 123464282 TCJA  Support
  # 2  2018 170169205 TCJA  Support
  # 3  2018 175996005 TCJA  Support
  # 4  2018 176818556 TCJA  Oppose
  # 5  2018 202120533 TCJA  Oppose
  # 6  2018 226449148 TCJA  Oppose
  # 7  2018 238205342 TCJA  Oppose
  # 8  2018 238806466 TCJA  Support
  # 9  2018 267564481 TCJA  Support
  # … with 59,991 more rows
 }

}
